<?php
/*************************************************

模型 - the 
Author: reload <17-8-16>

*************************************************/
namespace Home\Model;
use Think\Model\RelationModel;
class BillModel extends RelationModel {

    //查询数据
    public function get_all($map){
        $data = $this->where($map)->select();
        return $data;
    }

      public function get_all_page($map,$page,$pagenum){
        $data = $this->where($map)->limit($page,$pagenum)->select();
        return $data;
    }

    public function get_one($map) {
        $data = $this->where($map)->find();
        return $data;
    }

    //入账数据相加
    public function sum($map) {
        $data = M('Bill')->where($map)->sum('quota');
        return $data;
        // $sql = 'SELECT SUM(quota) as "Total Quota" FROM jg_bill WHERE status = 0';
        // $data = mysql_query($sql);
    }

    //手续费相加
    public function ded($map) {
        $data = M('Bill')->where($map)->sum('deduction');
        return $data;
        // $sql = 'SELECT SUM(quota) as "Total Quota" FROM jg_bill WHERE status = 0';
        // $data = mysql_query($sql);
    }

    //手续费
    public function count($map) {
        $data = M('Bill')->where($map)->count();
    //    echo $data->_sql();
        return $data;
    }

    //插入数据
    public function add($data) {
        $data = M('Bill')->add($data);
        return $data;
    }

     //统计投资额
    public function m_sum($map){
        $count = M('Bill')->where($map)->sum('quota');

        return($count);
    }

}